import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "",
      name: "",
      component: () => import("@/views/HomeView.vue"),
      redirect: "/index",
      children: [
        {
          path: "/index",
          name: "index",
          component: () => import("@/views/home/index.vue"),
        },
        {
          path: "/learning",
          name: "learning",
          component: () => import("@/views/learning/index.vue"),
        },
        {
          path: "/learning/statistics",
          name: "learningStatistics",
          component: () => import("@/views/learning/statistics/home.vue"),
        },
        {
          path: "/learning/listening",
          name: "learningListening",
          component: () => import("@/views/learning/listening.vue"),
        },
        {
          path: "/learning/learning",
          name: "learningLearning",
          component: () => import("@/views/learning/learning.vue"),
        },
        {
          path: "/learning/selfTest",
          name: "learningSelfTest",
          component: () => import("@/views/learning/test.vue"),
        },
        {
          path: "/learning/review",
          name: "learningReview",
          component: () => import("@/views/learning/review.vue"),
        },
        {
          path: "/learning/listeningPractice",
          name: "ListeningPractice",
          component: () => import("@/views/learning/listeningPractice.vue"),
        },
        {
          path: "video",
          name: "Video",
          component: () => import("@/views/training/video.vue"),
        },
        {
          path: "file",
          name: "File",
          component: () => import("@/views/training/file.vue"),
        },
        {
          path: "/test",
          name: "test",
          component: () => import("@/views/test/index.vue"),
          redirect: "/test/info",
          children: [
            {
              path: "info",
              name: "testInfo",
              component: () => import("@/views/test/info.vue"),
            },
            {
              path: "myexams",
              name: "testMyExams",
              component: () => import("@/views/test/myexams.vue"),
            },
            {
              path: "analysis",
              name: "testAnalysis",
              component: () => import("@/views/test/analysis.vue"),
            },
          ],
        },
        {
          path: "/test/answer",
          name: "testAnswer",
          component: () => import("@/views/test/answer.vue"),
        },
        {
          path: "/test/startTest",
          name: "StartTest",
          component: () => import("@/views/learning/test.vue"),
        },
        {
          path: "/training",
          name: "training",
          component: () => import("@/views/training/index.vue"),
          redirect: "/training/courses",
          children: [
            {
              path: "courses",
              name: "trainingCourses",
              component: () => import("@/views/training/courses.vue"),
            },
            {
              path: "certificates",
              name: "trainingCertificates",
              component: () => import("@/views/training/certificates.vue"),
            },
          ],
        },
        {
          path: "/trainingexam",
          name: "trainingExam",
          component: () => import("@/views/learning/test.vue"),
        },
        {
          path: "/my",
          name: "my",
          component: () => import("@/views/my/home.vue"),
          redirect: "/my/index",
          children: [
            {
              path: "index",
              name: "myIndex",
              component: () => import("@/views/my/index.vue"),
            },
            {
              path: "login",
              name: "login",
              component: () => import("@/views/my/login.vue"),
            },
          ],
        },
      ],
    },
    {
      path: "/:pathMatch(.*)*",
      name: "NotFound",
      component: () => import("@/views/NotFound.vue"),
    },
  ],
});

export default router;
